import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import dsd from '@dfeidao/atom-web/msg/javadsd';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import render from '@dfeidao/atom-web/render/render';
import { systemid } from '../../atom/config';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';
interface Aa {
	docDataStore: {
		audit_list: {
			dataArray: [];
			summary: {
				totalRow: number
			}
		}
	};
}
import p001 from './p001';

export default async function a003(fd: IFeidaoAiBrowserComponent, args: { currentTarget: HTMLElement }) {
	const page_name = fd.data.node.getAttribute('page-name');
	// 动态详情点赞/取消点赞
	const productid = get(fd, 'productid');
	const employee_no = get(fd, 'staff_no');
	const post_numbering = get(fd, 'dynamic_id');
	const dynamic_head = get(fd, 'dynamic_head');
	const isa = args.currentTarget.getAttribute('data-isa');
	console.log("9999999999");
	let flag = parseInt(isa, 10);
	console.log(flag);
	try {
		show_loading();
		const res = await nodejs(page_name + '/zj-000001/s004', { employee_no, productid, post_numbering, flag });
		// 点赞
		if (flag === 0) {
			const conditions = {
				"param": {
					"staff_no": employee_no,
					"administrator": "",
					"asso_type": '部门动态',
					"asso_title": dynamic_head,
					"asso_no": 'LX1002',
					"productid": productid
				}
			};
			const res2: Aa = await dsd(systemid, '', 'kinth_oadsd0000019', conditions);
			if (res2) { }
		} else {
			const conditions = {
				"param": {
					"staff_no": employee_no,
					"administrator": '',
					"asso_type": '部门动态',
					"asso_title": dynamic_head,
					"asso_no": 'LX1007',
					"productid": productid
				}
			};
			const res2: Aa = await dsd(systemid, '', 'kinth_oadsd0000019', conditions);
			if (res2) { }
		}

		hide_loading();
		if (res === 'success') {
			flag = (flag + 1) % 2;
			render(fd, flag, p001, 'p001', 'inner');
		} else {
			error('操作失败');
		}
	} catch (e) {
		hide_loading();
		error('操作失败');
	}
}
